package com.linkface.idcard;

import android.content.Context;
import android.graphics.Bitmap;

import com.linkface.card.CardRecognizer;

import java.util.Map;

import cn.linkface.ocr.LFCardDetector;
import cn.linkface.ocr.LFCardRecognizeListener;

/**
 * Copyright (c) 2017-2018 LINKFACE Corporation. All rights reserved.
 */
public class IDCardRecognizer extends CardRecognizer {
    private static final String TAG = IDCardRecognizer.class.getSimpleName();

    LFCardDetector detector;

    /**
     * 身份证识别模式
     */
    private int mode;


    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public IDCardRecognizer(Context context) {
        super(context);
        detector = new LFCardDetector(mContext);
    }

    @Override
    public void recognizeCard(int isAuto, Bitmap bitmap, boolean isVertical, Map<String, Object> extraRequestParams, LFCardRecognizeListener cardRecognizeListener) {
        detector.detectIDCard(isAuto, isVertical, bitmap, getMode(), extraRequestParams, cardRecognizeListener);
    }

    @Override
    public void releaseRecognizer() {
        detector.close();
    }

}
